+2008-02-12 Matthias Clasen <mclasen@redhat.com>
+
+ Skip exensions when selecting filenames in the save-as dialog.
+ (#362516, Carlos Garnacho)
+
+ * gtk/gtkfilechooserentry.h:
+ * gtk/gtkfilechooserentry.c (_gtk_file_chooser_entry_select_filename):
+ New function to skip the extension part when selecting a filename.
+ (_gtk_file_chooser_entry_set_base_folder): Use it here.
+
+ * gtk/gtkfilechooserdefault.c (gtk_file_chooser_entry_grab_focus):
+ ...and here.
+
2008-02-12 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkiconview.c: Fix state change reporting for
change_entry = TRUE; /* ... unless we are in one of the folder modes */
if (change_entry)
- _gtk_file_chooser_entry_set_file_part (GTK_FILE_CHOOSER_ENTRY (impl->location_entry),
- impl->browse_files_last_selected_name);
+ {
+ _gtk_file_chooser_entry_set_file_part (GTK_FILE_CHOOSER_ENTRY (impl->location_entry), impl->browse_files_last_selected_name);
+
+ if (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE)
+ _gtk_file_chooser_entry_select_filename (GTK_FILE_CHOOSER_ENTRY (impl->location_entry));
+ }
return;
}
static void gtk_file_chooser_entry_finalize (GObject *object);
static void gtk_file_chooser_entry_dispose (GObject *object);
+static void gtk_file_chooser_entry_grab_focus (GtkWidget *widget);
static gboolean gtk_file_chooser_entry_focus (GtkWidget *widget,
GtkDirectionType direction);
static void gtk_file_chooser_entry_activate (GtkEntry *entry);
gobject_class->finalize = gtk_file_chooser_entry_finalize;
gobject_class->dispose = gtk_file_chooser_entry_dispose;
+ widget_class->grab_focus = gtk_file_chooser_entry_grab_focus;
widget_class->focus = gtk_file_chooser_entry_focus;
entry_class->activate = gtk_file_chooser_entry_activate;
add_completion_idle (GTK_FILE_CHOOSER_ENTRY (editable));
}
+static void
+gtk_file_chooser_entry_grab_focus (GtkWidget *widget)
+{
+ GTK_WIDGET_CLASS (_gtk_file_chooser_entry_parent_class)->grab_focus (widget);
+ _gtk_file_chooser_entry_select_filename (GTK_FILE_CHOOSER_ENTRY (widget));
+}
+
static gboolean
gtk_file_chooser_entry_focus (GtkWidget *widget,
GtkDirectionType direction)
chooser_entry->base_folder = gtk_file_path_copy (path);
gtk_file_chooser_entry_changed (GTK_EDITABLE (chooser_entry));
- gtk_editable_select_region (GTK_EDITABLE (chooser_entry), 0, -1);
+ _gtk_file_chooser_entry_select_filename (chooser_entry);
}
/**
return retval;
}
+
+
+/*
+ * _gtk_file_chooser_entry_select_filename:
+ * @chooser_entry: a #GtkFileChooserEntry
+ *
+ * Selects the filename (without the extension) for user edition.
+ */
+void
+_gtk_file_chooser_entry_select_filename (GtkFileChooserEntry *chooser_entry)
+{
+ const gchar *str, *ext;
+ glong len = -1;
+
+ if (chooser_entry->action == GTK_FILE_CHOOSER_ACTION_SAVE)
+ {
+ str = gtk_entry_get_text (GTK_ENTRY (chooser_entry));
+ ext = g_strrstr (str, ".");
+
+ if (ext)
+ len = g_utf8_pointer_to_offset (str, ext);
+ }
+
+ gtk_editable_select_region (GTK_EDITABLE (chooser_entry), 0, (gint) len);
+}
+